#include <my_head.h>

void sig_func(int signum){
    printf("收了一个SIGALRM信号\n");
}

int main(int argc, const char *argv[]){
    signal(SIGALRM, sig_func);
    int ret = 0;
    ret = alarm(10);
    printf("ret = %d\n", ret); // 0
    sleep(2);
    ret = alarm(5);
    printf("ret = %d\n", ret); // 8
    // 一共 7 秒后收到信号
    int i = 0;
    while(1){
        printf("hello world %d\n", ++i);
        sleep(1);
    }
    return 0;
}